package com.ruoyi.system.util;

import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Field;

public class BeanUtils {
    /**
     * 判断对象中属性值是否全为空
     *
     * @param object
     * @return
     */
    public static void checkObjAllFieldsIsNull(Object object,Object value) {
        if (null == object) {
            return;
        }

        try {
            for (Field f : object.getClass().getDeclaredFields()) {
                f.setAccessible(true);

                System.out.print(f.getName() + ":");
                System.out.println(f.get(object));

                if (f.get(object) == null || !StringUtils.isNotBlank(f.get(object).toString()) || "null".equals(f.get(object).toString().trim())) {
                    System.out.print(f.getName() + ":");
                    System.out.println(f.get(object));
                    f.set(object,value);
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
